﻿using HikRcsService.Common;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using WCS_Utility.ConstString;

namespace HikRcsService._631_Optical
{
    /// <summary>
    /// 光通信功能码和海康API对应
    /// </summary>
    public class OpticalFunCodeApiMap
    {
        public async Task<string> GetFunCodeBaseApi(string api)
        {
            var funCode = api switch
            {
                HikRcsConst.genAgvSchedulingTask => OpticalFunCode.genAgvSchedulingTaskCode,
                HikRcsConst.continueTask => OpticalFunCode.continueTaskCode,
                HikRcsConst.cancelTask => OpticalFunCode.cancelTaskCode,
                HikRcsConst.agvCallback => OpticalFunCode.agvCallbackCode,
                HikRcsConst.queryTaskStatus => OpticalFunCode.queryTaskStatusCode,
                HikRcsConst.queryAgvStatus => OpticalFunCode.queryAgvStatusCode,
                HikRcsConst.stopRobot => OpticalFunCode.stopRobotCode,
                HikRcsConst.resumeRobot => OpticalFunCode.resumeRobotCode,
                HikRcsConst.genCtuGroupTaskBatch => OpticalFunCode.genCtuGroupTaskBatchCode,
                HikRcsConst.boxApplyPass => OpticalFunCode.boxApplyPassCode,
                HikRcsConst.warnCallback => OpticalFunCode.warnCallbackCode,
                HikRcsConst.applyReturnForValid => OpticalFunCode.applyReturnForValidCode,
                HikRcsConst.applyReturnForBin => OpticalFunCode.applyReturnForBinCode,
                HikRcsConst.setTaskPriority => OpticalFunCode.setTaskPriorityCode,
                HikRcsConst.bindPodAndBerth => OpticalFunCode.bindPodAndBerthCode,
                HikRcsConst.bindPodAndMat => OpticalFunCode.bindPodAndMatCode,
                HikRcsConst.lockPosition => OpticalFunCode.lockPositionCode,
                HikRcsConst.syncMapDatas => OpticalFunCode.syncMapDatasCode,
                HikRcsConst.queryPodBerthAndMat => OpticalFunCode.queryPodBerthAndMatCode,
                HikRcsConst.blockStgBin => OpticalFunCode.blockStgBinCode,
                HikRcsConst.clearRoadWay => OpticalFunCode.clearRoadWayCode,
                HikRcsConst.getOutPod => OpticalFunCode.getOutPodCode,
                HikRcsConst.returnPod => OpticalFunCode.returnPodCode,
                HikRcsConst.chargeReport => OpticalFunCode.chargeRequestCode,
                HikRcsConst.genPreScheduleTask => OpticalFunCode.PreScheduleTask,
                _ => ""
            } ;

            return funCode;
        }

        public async Task<string> GetFunCodeBaseAgvPeripheral(string peripheral)
        {
            var funCode = peripheral switch
            {
                ConstStringData.Roller_Peripheral => OpticalFunCode.RollerCode,
                ConstStringData.Promptlight_Peripheral => OpticalFunCode.Promptlight,
                _ => ""
            };
            return funCode;
        }

        public async Task<string> GetApiBaseFunCode(string funCode)
        {
            var apiName = funCode switch
            {
                OpticalFunCode.genAgvSchedulingTaskCode => HikRcsConst.genAgvSchedulingTask,
                OpticalFunCode.continueTaskCode => HikRcsConst.continueTask,
                OpticalFunCode.cancelTaskCode => HikRcsConst.cancelTask,
                OpticalFunCode.agvCallbackCode => HikRcsConst.agvCallback,
                OpticalFunCode.queryTaskStatusCode => HikRcsConst.queryTaskStatus,
                OpticalFunCode.queryAgvStatusCode => HikRcsConst.queryAgvStatus,
                OpticalFunCode.stopRobotCode => HikRcsConst.stopRobot,
                OpticalFunCode.resumeRobotCode => HikRcsConst.resumeRobot,
                OpticalFunCode.genCtuGroupTaskBatchCode => HikRcsConst.genCtuGroupTaskBatch,
                OpticalFunCode.boxApplyPassCode => HikRcsConst.boxApplyPass,
                OpticalFunCode.warnCallbackCode => HikRcsConst.warnCallback,
                OpticalFunCode.applyReturnForValidCode => HikRcsConst.applyReturnForValid,
                OpticalFunCode.applyReturnForBinCode => HikRcsConst.applyReturnForBin,
                OpticalFunCode.setTaskPriorityCode => HikRcsConst.setTaskPriority,
                OpticalFunCode.bindPodAndBerthCode => HikRcsConst.bindPodAndBerth,
                OpticalFunCode.bindPodAndMatCode => HikRcsConst.bindPodAndMat,
                OpticalFunCode.lockPositionCode => HikRcsConst.lockPosition,
                OpticalFunCode.syncMapDatasCode => HikRcsConst.syncMapDatas,
                OpticalFunCode.queryPodBerthAndMatCode => HikRcsConst.queryPodBerthAndMat,
                OpticalFunCode.blockStgBinCode => HikRcsConst.blockStgBin,
                OpticalFunCode.clearRoadWayCode => HikRcsConst.clearRoadWay,
                OpticalFunCode.getOutPodCode => HikRcsConst.getOutPod,
                OpticalFunCode.returnPodCode => HikRcsConst.returnPod,
            };

            return apiName;
        }
    }
}
